package com.csun.cmny.provider.device.watch.entity;

    /// <summary>
    ///  上行短信触发请求数据包
    ///  没有下行确认 
    ///  a.此请求应保持 60S 网络链接等待服务器端下发响应数据。
    ///  b.服务器的下行响应数据接口，就是本文中任何一个下行的接口，终端要根据相应的接口要求进行处理。
    ///  c.由于短信运营商下发短信并不是纯密钥形式(内容中会带有短信标志前缀)，所以需要在收到短信后，在短信全文中搜索是否包含双方已约定密钥字段再进行后续处理。
    ///  Upstream SMS trigger request packet No downlink acknowledgement
    ///  a.This request should keep the 60S network link waiting for the server to send response data.
    /// b.The server's downstream response data interface is any one of the downlink interfaces in this document. The terminal shall handle the interface according to the corresponding interface requirements.
    /// c.Since short message operators send SMS messages that are not in the form of a pure key (messages will be prefixed with a short message mark), after receiving a short message, it is necessary to search the full text of the message to see if it contains both agreed-upon key fields and follow-up.deal with.
    /// </summary>
    public class C039
    {
        /// <summary>
        /// 数据起封包 @B#@ 
        /// Start Fixed value :@B#@ 
        /// </summary>
        public String HeadCode = "@B#@";
        /// <summary>
        /// 协议版本号
        /// Protocol version number
        /// </summary>
        public String Protocol = null;
        /// <summary>
        /// 功能代码识别
        /// Function code
        /// </summary>
        public final String FunCode = "039";
        /// <summary>
        /// 国际移动设备身份码
        /// International Mobile Equipment Identity
        /// </summary>
        public String IMEI = null;
        /// <summary>
        /// 国际移动用户识别码
        /// International Mobile Subscriber Identification Number
        /// </summary>
        public String IMSI = null;
        /// <summary>
        /// 终端当前时间(年月日时分秒) yyyyMMddHHmmss
        /// The terminal current time ( format:yyyyMMddHHmmss)
        /// </summary>
        public String TerminalTime = null;
        /// <summary>
        /// 佩戴状态 （0:未佩戴 ;1:已佩戴）
        /// Terminal wear state  (0: is not worn; 1: is worn)
        /// </summary>
        public int WearState = 0;
        /// <summary>
        /// 剩余电量百分比（range:1-100）
        /// Percentage of residual electricity (range:1-100)
        /// </summary>
        public int Power = 0;
        /// <summary>
        /// 结尾封包 @E#@
        /// End packet @E#@
        /// </summary>
        public String FootCode = "@E#@";



        /// <summary>
        /// 初始化模型
        ///@B#@|01|039|111112222233333|8888888888888888|20160715153805|1|54|@E#@
        /// </summary>
        /// <param name="cmdStr">命令代码</param>
        public C039(String cmdStr)
        {
        	String[] data = cmdStr.split("\\|");
            int dataLength = data.length;
            if (dataLength == 9 && "@B#@".equals(data[0]) && FunCode.equals(data[2]))
            {
                HeadCode = data[0];
                Protocol = data[1];
                IMEI = data[3];
                IMSI = data[4];
                TerminalTime = data[5];
                WearState = Integer.parseInt(data[6]);
                Power = Integer.parseInt(data[7]);
                FootCode = data[8];
            }

        }

        public  String ToString()
        {
        	String rString = HeadCode + "|";
            rString += Protocol + "|";
            rString += FunCode + "|";
            rString += IMEI + "|";
            rString += IMSI + "|";
            rString += TerminalTime + "|";
            rString += WearState + "|";
            rString += Power + "|";
            rString += FootCode;
            return rString;
        }
    }




